package com.api.workflow.action;

import com.engine.common.util.ServiceUtil;
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
import com.engine.workflow.publicApi.WorkflowRequestOperatePA;
import com.engine.workflow.publicApi.impl.WorkflowRequestOperatePAImpl;
import weaver.conn.RecordSet;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

public class SubprocessSubmissionAction implements Action {
    @Override
    public String execute(RequestInfo requestInfo) {
        // 表单名称
        String tableName = requestInfo.getRequestManager().getBillTableName();
        // 表单数据ID
        int bill_id = requestInfo.getRequestManager().getBillid();
        String sql = "select zmrequestid,zmid from "+ tableName +" where id = "+ bill_id;
        RecordSet recordSet = new RecordSet();
        recordSet.execute(sql);
        if (recordSet.next()){
            String zmrequestid = recordSet.getString("zmrequestid");
            String zmid = recordSet.getString("zmid");

            WorkflowRequestOperatePA service = ServiceUtil.getService(WorkflowRequestOperatePAImpl.class);
            ReqOperateRequestEntity reqOperateRequestEntity = new ReqOperateRequestEntity();
            User user = new User(Integer.parseInt(zmid));
            reqOperateRequestEntity.setRequestId(Integer.parseInt(zmrequestid));
            service.submitRequest(user,reqOperateRequestEntity);
        }
        return SUCCESS;
    }
}
